/*
 * Copyright 2013 Agustina Martinez-Garcia

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package uk.ljmu.qudexapps.xmllib.services;

import java.util.List;

import org.igfay.jfig.JFigException;

import uk.ljmu.mulgaraifz.errorhandling.MulgaraException;
import uk.ljmu.qudexapps.xmllib.exceptions.FedoraException;
import uk.ljmu.qudexapps.xmllib.exceptions.GraphException;
import uk.ljmu.qudexapps.xmllib.model.CollectionElement;

public interface FedoraMulgaraService {
    /**
     * 
     * @param colidentifier
     * @throws JFigException
     * @throws MulgaraException
     * @throws GraphException
     * @throws FedoraException
     */
    public void createGraphByCollection(String colidentifier) throws JFigException, MulgaraException, GraphException,
    FedoraException;
    /**
     * 
     * @param graphURL
     * @return
     */
    public boolean dropGraph(String graphURL);
    /**
     * 
     * @return
     */
    public String getGraphURL();
    /**
     * Queries Mulgara to find all the associated File object with a given collection
     * 
     * @param qudexCollectionPid the Qudex Collection Fedora Pid
     * @return list with the Fedora PIDs for all the collection's dependant qudex documents
     */
    public List<String> retrieveDependantQudexDocuments(String qudexCollectionPid);
    /**
     * Queries Mulgara to find all the qudex collections in the repository
     * @param collectionsPrefix default qudex prefix
     * @return list with the collections PIDs
     */
    public List<String> retrieveQudexCollections(
	    String collectionsPrefix, String collectionId);
    /**
     * Returns whether a given collection is a sub-collection or a parent collection
     * @param collectionId Fedora PID of the collection to find
     * @return true if the collection is a sub-collection, false otherwise
     * @throws MulgaraException 
     */
    public boolean isSubCollection(String collectionId) throws MulgaraException;
    /**
     * @param startingCollection
     * @throws MulgaraException 
     */
    public void findRootCollection(String startingCollection) throws MulgaraException;
    /**
     * 
     * @return
     */
    public String getRootCollectionPid();
    /**
     * 
     * @param rootCollectionPid
     */
    public void setRootCollectionPid(String rootCollectionPid);
    
    public boolean isMulgaraRunning();
    
    public boolean isFedoraRunning();
    
    // TREE FUNCTIONS
    public List<CollectionElement> constructCollectionsTree(String prefix);
    
    public String getCollectionRootParent(String collectionId, String prefix);
    
    public void cleanInstance();
    
	public List<String> retrieveQudexRootCollections(String qudexPrefix);
	
	public List<String> retrieveQudexInstanceCollections(String qudexPrefix);
	
	public boolean collectionContainsInstance(String collectionId) throws MulgaraException;
	
	public List<String> retrieveQudexCollectionFiles(String collectionId);
	
	public String retrieveObjectTitle(String fedoraPid);
	//AMG ADDED SEPT 2013
	public String retrieveCategoryPID(String catLabel, String collectionID);
}
